package com.stark.commons.spring.web.support.eureka;

import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent;
import org.springframework.context.ApplicationListener;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * eureka 服务续约事件监听器。
 * @author Ben
 * @since 1.0.0
 * @version 1.0.0
 */
@Data
@AllArgsConstructor
public class RenewedEventListener implements ApplicationListener<EurekaInstanceRenewedEvent> {
	
	private RenewedEventHandler renewedEventHandler;

	@Override
	public void onApplicationEvent(EurekaInstanceRenewedEvent event) {
		if (!event.isReplication()) {
			renewedEventHandler.handle(event);
		}
	}

}
